package com.example.b_308.myapplication.view.main;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.view.base.BaseActivity;

import java.util.List;

/**
 * Created by xxtves on 2017/11/22.
 */

public  class MessageAdapter extends BaseLvAdapter implements View.OnClickListener{
    List<MessageBeen> messageBeenList;
    LayoutInflater inflater;
    Context context;

//    public void notifyChange(List<MessageBeen>messageBeens){
//        this.messageBeenList=messageBeens;
//        notifyDataSetChanged();
//    }

    public MessageAdapter(List<MessageBeen> messageBeenList,Context context) {
        this.messageBeenList = messageBeenList;
        this.context = context;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return messageBeenList.size();
    }

    @Override
    public MessageBeen getItem(int position) {
        return messageBeenList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoder viewHoder;
        if (null==convertView){
            convertView =inflater.inflate(R.layout.item_message,null,false);
            viewHoder =new ViewHoder(convertView);
            convertView.setTag(viewHoder);
        }else{
            viewHoder= (ViewHoder) convertView.getTag();
            viewHoder.textView.setText(getItem(position).getStaff().getName());
        }
        return convertView;
    }

    @Override
    public void onClick(View view) {

    }

    class ViewHoder{
        View contentView;
        TextView textView;

        public ViewHoder(View contentView){
            this.contentView=contentView;
            textView= (TextView) contentView.findViewById(R.id.tv_message);
        }

    }
}
